﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using Maticsoft.Model;
namespace Maticsoft.BLL
{
    //QFQCson
    public partial class QFQCson
    {

        private readonly Maticsoft.DAL.QFQCson dal = new Maticsoft.DAL.QFQCson();
        public QFQCson()
        { }

        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            return dal.Exists(ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.QFQCson model)
        {
            return dal.Add(model);

        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.QFQCson model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {

            return dal.Delete(ID);
        }
        /// <summary>
        /// 批量删除一批数据
        /// </summary>
        public bool DeleteList(string IDlist)
        {
            return dal.DeleteList(IDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.QFQCson GetModel(int ID)
        {

            return dal.GetModel(ID);
        }


        public int Delete(string where)
        {

            return dal.Delete(where);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Maticsoft.Model.QFQCson> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Maticsoft.Model.QFQCson> DataTableToList(DataTable dt)
        {
            List<Maticsoft.Model.QFQCson> modelList = new List<Maticsoft.Model.QFQCson>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Maticsoft.Model.QFQCson model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Maticsoft.Model.QFQCson();
                    if (dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["FS03"].ToString() != "")
                    {
                        model.FS03 = int.Parse(dt.Rows[n]["FS03"].ToString());
                    }
                    model.FS04 = dt.Rows[n]["FS04"].ToString();
                    model.FS05 = dt.Rows[n]["FS05"].ToString();
                    model.FS06 = dt.Rows[n]["FS06"].ToString();
                    model.FS07 = dt.Rows[n]["FS07"].ToString();
                    model.FS08 = dt.Rows[n]["FS08"].ToString();
                    model.FS09 = dt.Rows[n]["FS09"].ToString();
                    model.FS10 = dt.Rows[n]["FS10"].ToString();
                    model.FS11 = dt.Rows[n]["FS11"].ToString();
                    if (dt.Rows[n]["FS12"].ToString() != "")
                    {
                        model.FS12 = int.Parse(dt.Rows[n]["FS12"].ToString());
                    }
                    model.CRP = dt.Rows[n]["CRP"].ToString();
                    model.FS03sum = dt.Rows[n]["FS03sum"].ToString();
                    model.FS08sum = dt.Rows[n]["FS08sum"].ToString();
                    model.FS13 = dt.Rows[n]["FS13"].ToString();
                    model.FS15 = dt.Rows[n]["FS15"].ToString();
                    model.FS14 = dt.Rows[n]["FS14"].ToString();
                    model.FS16 = dt.Rows[n]["FS16"].ToString();
                    model.FS17 = dt.Rows[n]["FS17"].ToString();
                    model.FS18 = dt.Rows[n]["FS18"].ToString();
                    model.FS19 = dt.Rows[n]["FS19"].ToString();
                    if (dt.Rows[n]["FS20"].ToString() != "")
                    {
                        model.FS20 = int.Parse(dt.Rows[n]["FS20"].ToString());
                    }
                    if (dt.Rows[n]["CRT"].ToString() != "")
                    {
                        model.CRT = DateTime.Parse(dt.Rows[n]["CRT"].ToString());
                    }
                    if (dt.Rows[n]["FS21"].ToString() != "")
                    {
                        model.FS21 = int.Parse(dt.Rows[n]["FS21"].ToString());
                    }
                    if (dt.Rows[n]["FS22"].ToString() != "")
                    {
                        model.FS22 = int.Parse(dt.Rows[n]["FS22"].ToString());
                    }
                    if (dt.Rows[n]["FS23"].ToString() != "")
                    {
                        model.FS23 = int.Parse(dt.Rows[n]["FS23"].ToString());
                    }
                    model.MODP = dt.Rows[n]["MODP"].ToString();
                    if (dt.Rows[n]["MODT"].ToString() != "")
                    {
                        model.MODT = DateTime.Parse(dt.Rows[n]["MODT"].ToString());
                    }
                    if (dt.Rows[n]["FLAG"].ToString() != "")
                    {
                        model.FLAG = int.Parse(dt.Rows[n]["FLAG"].ToString());
                    }
                    model.AId = dt.Rows[n]["AId"].ToString();
                    model.FS01 = dt.Rows[n]["FS01"].ToString();
                    model.FS02 = dt.Rows[n]["FS02"].ToString();


                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }
        #endregion

    }
}